package fhp.hlhj.giantfold
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import fhp.hlhj.giantfold.presenter.BasePresenter
import fhp.hlhj.giantfold.utils.MyUtils
abstract class BaseActivity2<V,T : BasePresenter<V>> : AppCompatActivity() {
    lateinit var basePresenter:T
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(getContentId())
        MyUtils.setWindowStatusBarColor(this,getStatusColor())
        basePresenter=createPresenter()
        if (basePresenter!=null){
            basePresenter.attachView(this as V)
        }
        initSet()
        initView()
        initData()
        initListener()
    }

    open fun createPresenter(): T{
        return basePresenter
    }

    open fun initData() {

    }

    override fun onDestroy() {
        basePresenter.detachView()
        super.onDestroy()
    }
    private fun initSet() {
        supportActionBar?.hide()
    }
    open fun getStatusColor():Int{
        return R.color.colorPrimaryDark
    }
    protected abstract fun getContentId():Int
    open fun initListener() {

    }
    open fun initView() {
    }
}
